function MartinsSimilarityMap(container) {
	this.containerElement = container;
	this.data = null;
	this.options = [];
	this.headers = [];
}

function callbackReady() {
	getFlexApp('simmap').getDataObjects(vis.headers, vis.data, vis.options);
}

MartinsSimilarityMap.prototype.draw = function(data, options) {
	if (options.inverse_data == false) {
		this.data = new Array(data.getNumberOfRows() + 1);

		// compute data
		this.data[0] = new Array(data.getNumberOfColumns() - 1);
		for ( var i = 0; i < data.getNumberOfColumns(); i++) {
			if (i == 0) {
				this.headers[i] = data.getColumnLabel(i);
			} else {
				this.data[0][i - 1] = data.getColumnLabel(i);
			}
		}

		for ( var row = 1; row < data.getNumberOfRows() + 1; row++) {
			this.headers[row] = data.getValue(row - 1, 0);

			this.data[row] = new Array(data.getNumberOfColumns() - 1);
			for ( var column = 1; column < data.getNumberOfColumns(); column++) {
				if (data.getFormattedValue(row - 1, column).indexOf('%') != -1
						&& ('' + data.getValue(row - 1, column)).indexOf('%') == -1) {
					this.data[row][column - 1] = data.getValue(row - 1, column) * 100;
				} else {
					this.data[row][column - 1] = data.getValue(row - 1, column);
				}
			}
		}
	} else {
		this.data = new Array(data.getNumberOfColumns());

		// compute data
		for ( var column = 0; column < data.getNumberOfColumns(); column++) {
			this.headers[column] = data.getColumnLabel(column);

			this.data[column] = new Array(data.getNumberOfRows());
			for ( var row = 0; row < data.getNumberOfRows(); row++) {
				if (this.data[column][row] < 0) {
					alert("No negative values allowed! Aborting!");
					return;
				}

				if (data.getFormattedValue(row, column).indexOf('%') != -1
						&& ('' + data.getValue(row, column)).indexOf('%') == -1) {
					this.data[column][row] = data.getValue(row, column) * 100;
				} else {
					this.data[column][row] = data.getValue(row, column);
				}
			}
		}
	}

	// option mapping
	this.options[0] = options.use_cookies;
	this.options[1] = options.chartWidth;
	this.options[2] = options.chartHeight;
	this.options[3] = options.inverse_data;
	this.options[4] = 'https://bakk.googlecode.com/git/gadgets/';

	if (options.use_cookies) {

		this.options[5] = options.use_default_settings;
		this.options[6] = options.store_changes_in_cookie;
		this.options[7] = options.cookie_id;
		this.options[8] = options.number_input_format;

	} else {

		this.options[5] = false;
		this.options[6] = false;
		this.options[7] = '';
		this.options[8] = options.number_input_format;

		this.options[9] = options.number_display_format;
		this.options[10] = options.show_legend;
		this.options[11] = options.hide_title;
		this.options[12] = options.use_ratio;
		this.options[13] = options.x_ratio;
		this.options[14] = options.y_ratio;
		this.options[15] = options.title;
		this.options[16] = options.data_points;
		this.options[17] = options.data_point_size;
		this.options[18] = options.data_point_transparency;
		this.options[19] = options.color_scheme;
		this.options[20] = options.hide_entity_labels;
		this.options[21] = options.label_style;
		this.options[22] = options.show_labels_during_animation;
	}

	// create flash object
	if (this.containerElement != null) {
		var url = 'https://bakk.googlecode.com/git/gadgets/simmap/simmap.swf';
		var options = {
			id : "simmap",
			width : options.chartWidth,
			height : options.chartHeight,
			allowScriptAccess : "always"
		};
		gadgets.flash.embedFlash(url, "chart", "10.0.0", options);
		gadgets.window.adjustHeight();
	}
}